<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title><?php echo ($meta_title); ?>|管理平臺</title>
    <link href="/cuiyufan/Public/favicon.ico" type="image/x-icon" rel="shortcut icon">
    <link rel="stylesheet" type="text/css" href="/cuiyufan/Public/Admin/css/base.css" media="all">
    <link rel="stylesheet" type="text/css" href="/cuiyufan/Public/Admin/css/common.css" media="all">
    <link rel="stylesheet" type="text/css" href="/cuiyufan/Public/Admin/css/module.css">
    <link rel="stylesheet" type="text/css" href="/cuiyufan/Public/Admin/css/style.css" media="all">
	<link rel="stylesheet" type="text/css" href="/cuiyufan/Public/Admin/css/<?php echo (C("COLOR_STYLE")); ?>.css" media="all">
     <!--[if lt IE 9]>
    <script type="text/javascript" src="/cuiyufan/Public/static/jquery-1.10.2.min.js"></script>
    <![endif]--><!--[if gte IE 9]><!-->
    <script type="text/javascript" src="/cuiyufan/Public/static/jquery-2.0.3.min.js"></script>
    <script type="text/javascript" src="/cuiyufan/Public/Admin/js/jquery.mousewheel.js"></script>
    <!--<![endif]-->
    
</head>
<body>
    <!-- 頭部 -->
    <div class="header">
        <!-- Logo -->
        <span class="logo"><?php echo ($conf['WEB_SITE_TITLE']); ?></span>
        <!-- /Logo -->

        <!-- 主導航 -->
        <ul class="main-nav">
            <?php if(is_array($__MENU__["main"])): $i = 0; $__LIST__ = $__MENU__["main"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($i % 2 );++$i;?><li class="<?php echo ((isset($menu["class"]) && ($menu["class"] !== ""))?($menu["class"]):''); ?>"><a href="<?php echo (u($menu["url"])); ?>"><?php echo ($menu["title"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
        </ul>
        <!-- /主導航 -->

        <!-- 用戶欄 -->
        <div class="user-bar">
            <a href="javascript:;" class="user-entrance"><i class="icon-user"></i></a>
            <ul class="nav-list user-menu hidden">
                <li class="manager">妳好，<em title="<?php echo session('user_auth.username');?>"><?php echo session('user_auth.username');?></em></li>
                <li><a href="<?php echo U('User/updatePassword');?>">修改密碼</a></li>
                <li><a href="<?php echo U('User/updateNickname');?>">修改昵稱</a></li>
                <li><a href="<?php echo U('Public/logout');?>">退出</a></li>
            </ul>
        </div>
    </div>
    <!-- /頭部 -->

    <!-- 邊欄 -->
    <div class="sidebar">
        <!-- 子導航 -->
        
    <div id="subnav" class="subnav">
    <?php if(!empty($_extra_menu)): ?>
        <?php echo extra_menu($_extra_menu,$__MENU__); endif; ?>
    <?php if(is_array($__MENU__["child"])): $i = 0; $__LIST__ = $__MENU__["child"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$sub_menu): $mod = ($i % 2 );++$i;?><!-- 子導航 -->
        <?php if(!empty($sub_menu)): if(!empty($key)): ?><h3><i class="icon icon-unfold"></i><?php echo ($key); ?></h3><?php endif; ?>
            <ul class="side-sub-menu">
                <?php if(is_array($sub_menu)): $i = 0; $__LIST__ = $sub_menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($i % 2 );++$i;?><li>
                        <a class="item" href="<?php echo (u($menu["url"])); ?>"><?php echo ($menu["title"]); ?></a>
                    </li><?php endforeach; endif; else: echo "" ;endif; ?>
            </ul><?php endif; ?>
        <!-- /子導航 --><?php endforeach; endif; else: echo "" ;endif; ?>

    <?php if(is_array($nodes)): $i = 0; $__LIST__ = $nodes;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$sub_menu): $mod = ($i % 2 );++$i;?><!-- 子導航 -->
        <?php if(!empty($sub_menu)): ?><h3>
            	<i class="icon <?php if(($sub_menu['current']) != "1"): ?>icon-fold<?php endif; ?>"></i>
            	<?php if(($sub_menu['allow_publish']) > "0"): ?><a class="item" href="<?php echo (u($sub_menu["url"])); ?>"><?php echo ($sub_menu["title"]); ?></a><?php else: echo ($sub_menu["title"]); endif; ?>
            </h3>
            <ul class="side-sub-menu <?php if(($sub_menu["current"]) != "1"): ?>subnav-off<?php endif; ?>">
                <?php if(is_array($sub_menu['_child'])): $i = 0; $__LIST__ = $sub_menu['_child'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($i % 2 );++$i;?><li <?php if($menu['id'] == $cate_id or $menu['current'] == 1): ?>class="current"<?php endif; ?>>
                        <?php if(($menu['allow_publish']) > "0"): ?><a class="item" href="<?php echo (u($menu["url"])); ?>"><?php echo ($menu["title"]); ?></a><?php else: ?><a class="item" href="javascript:void(0);"><?php echo ($menu["title"]); ?></a><?php endif; ?>

                        <!-- 壹級子菜單 -->
                        <?php if(isset($menu['_child'])): ?><ul class="subitem">
                        	<?php if(is_array($menu['_child'])): foreach($menu['_child'] as $key=>$three_menu): ?><li>
                                <?php if(($three_menu['allow_publish']) > "0"): ?><a class="item" href="<?php echo (u($three_menu["url"])); ?>"><?php echo ($three_menu["title"]); ?></a><?php else: ?><a class="item" href="javascript:void(0);"><?php echo ($three_menu["title"]); ?></a><?php endif; ?>
                                <!-- 二級子菜單 -->
                                <?php if(isset($three_menu['_child'])): ?><ul class="subitem">
                                	<?php if(is_array($three_menu['_child'])): foreach($three_menu['_child'] as $key=>$four_menu): ?><li>
                                        <?php if(($four_menu['allow_publish']) > "0"): ?><a class="item" href="<?php echo U('index','cate_id='.$four_menu['id']);?>"><?php echo ($four_menu["title"]); ?></a><?php else: ?><a class="item" href="javascript:void(0);"><?php echo ($four_menu["title"]); ?></a><?php endif; ?>
                                        <!-- 三級子菜單 -->
                                        <?php if(isset($four_menu['_child'])): ?><ul class="subitem">
                                        	<?php if(is_array($four_menu['_child'])): $i = 0; $__LIST__ = $four_menu['_child'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$five_menu): $mod = ($i % 2 );++$i;?><li>
                                            	<?php if(($five_menu['allow_publish']) > "0"): ?><a class="item" href="<?php echo U('index','cate_id='.$five_menu['id']);?>"><?php echo ($five_menu["title"]); ?></a><?php else: ?><a class="item" href="javascript:void(0);"><?php echo ($five_menu["title"]); ?></a><?php endif; ?>
                                            </li><?php endforeach; endif; else: echo "" ;endif; ?>
                                        </ul><?php endif; ?>
                                        <!-- end 三級子菜單 -->
                                    </li><?php endforeach; endif; ?>
                                </ul><?php endif; ?>
                                <!-- end 二級子菜單 -->
                            </li><?php endforeach; endif; ?>
                        </ul><?php endif; ?>
                        <!-- end 壹級子菜單 -->
                    </li><?php endforeach; endif; else: echo "" ;endif; ?>
            </ul><?php endif; ?>
        <!-- /子導航 --><?php endforeach; endif; else: echo "" ;endif; ?>
    
    <!-- 留言板 -->  
    <h3>
        <i class="icon <?php if(!in_array((ACTION_NAME), explode(',',"feedback,feedbackdetail"))): ?>icon-fold<?php endif; ?>"></i>
        <a  class="item" href="<?php echo U('article/feedback');?>">留言板</a>
    </h3>
    <ul class="side-sub-menu subnav-off">
    </ul>
    
    <!-- 回收站 -->
	<?php if(($show_recycle) == "1"): ?><h3>
        <em class="recycle"></em>
        <a href="<?php echo U('article/recycle');?>">回收站</a>
    </h3><?php endif; ?>
</div>
<script>
    $(function(){
        $(".side-sub-menu li").hover(function(){
            $(this).addClass("hover");
        },function(){
            $(this).removeClass("hover");
        });
    })
</script>

        <!-- /子導航 -->
    </div>
    <!-- /邊欄 -->

    <!-- 內容區 -->
    <div id="main-content">
        <div id="top-alert" class="fixed alert alert-error" style="display: none;">
            <button class="close fixed" style="margin-top: 4px;">&times;</button>
            <div class="alert-content">這是內容</div>
        </div>
        <div id="main" class="main">
            
            <!-- nav -->
            <?php if(!empty($_show_nav)): ?><div class="breadcrumb">
                <span>您的位置:</span>
                <?php $i = '1'; ?>
                <?php if(is_array($_nav)): foreach($_nav as $k=>$v): if($i == count($_nav)): ?><span><?php echo ($v); ?></span>
                    <?php else: ?>
                    <span><a href="<?php echo ($k); ?>"><?php echo ($v); ?></a>&gt;</span><?php endif; ?>
                    <?php $i = $i+1; endforeach; endif; ?>
            </div><?php endif; ?>
            <!-- nav -->
            

            
    <script type="text/javascript" src="/cuiyufan/Public/static/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title cf">
        <h2>
            編輯<?php echo (get_document_model($data["model_id"],'title')); ?> [
            <?php if(is_array($rightNav)): $i = 0; $__LIST__ = $rightNav;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$nav): $mod = ($i % 2 );++$i;?><a href="<?php echo U('article/index','cate_id='.$nav['id']);?>"><?php echo ($nav["title"]); ?></a>
                <?php if(count($rightNav) > $i): ?><i class="ca"></i><?php endif; endforeach; endif; else: echo "" ;endif; ?>
            <?php if(isset($article)): ?>：<a href="<?php echo U('article/index','cate_id='.$data['category_id'].'&pid='.$article['id']);?>"><?php echo ($article["title"]); ?></a><?php endif; ?>
            ]
        </h2>
    </div>
    <!-- 標簽頁導航 -->
    <div class="tab-wrap">
        <ul class="tab-nav nav">
            <?php $_result=parse_config_attr($model['field_group']);if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$group): $mod = ($i % 2 );++$i;?><li data-tab="tab<?php echo ($key); ?>" <?php if(($key) == "1"): ?>class="current"<?php endif; ?>><a href="javascript:void(0);"><?php echo ($group); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
        </ul>
        <div class="tab-content">
            <!-- 表單 -->
            <form id="form" action="<?php echo U('update');?>" method="post" class="form-horizontal">
                <!-- 基礎文檔模型 -->
                <?php $_result=parse_config_attr($model['field_group']);if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$group): $mod = ($i % 2 );++$i;?><div id="tab<?php echo ($key); ?>" class="tab-pane <?php if(($key) == "1"): ?>in<?php endif; ?> tab<?php echo ($key); ?>">
                        <?php if(is_array($fields[$key])): $i = 0; $__LIST__ = $fields[$key];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$field): $mod = ($i % 2 );++$i; if($field['is_show'] == 1 || $field['is_show'] == 3): if($field['name']=='location'): ?><div class="form-item cf">
                                        <label class="item-label">地理位置<span class="check-tips">（選擇地圖坐標）</span></label>
                                        <div class="controls">
                                            <input class="text input-large" name="location" value="<?php echo ($data['location']); ?>" type="text"> <a target="_BLANK"  href="http://www.gpsspg.com/maps.htm">獲取坐標</a>                     </div>
                                    </div> 
                                    <?php else: ?>
                                    <div class="form-item cf">
                                        <label class="item-label"><?php echo ($field['title']); ?><span class="check-tips"><?php if(!empty($field['remark'])): ?>（<?php echo ($field['remark']); ?>）<?php endif; ?></span></label>
                                        <div class="controls">
                                            <?php switch($field["type"]): case "num": ?><input type="text" class="text input-medium" name="<?php echo ($field["name"]); ?>" value="<?php echo ($data[$field['name']]); ?>"><?php break;?>
                                            <?php case "string": ?><input type="text" class="text input-large" name="<?php echo ($field["name"]); ?>" value="<?php echo ($data[$field['name']]); ?>"><?php break;?>
                                            <?php case "textarea": ?><label class="textarea input-large">
                                                    <textarea name="<?php echo ($field["name"]); ?>"><?php echo ($data[$field['name']]); ?></textarea>
                                                </label><?php break;?>
                                            <?php case "datetime": ?><input type="text" name="<?php echo ($field["name"]); ?>" class="text input-large time" value="<?php echo (date('Y-m-d H:i',$data[$field['name']])); ?>" placeholder="請選擇時間" /><?php break;?>
                                            <?php case "bool": ?><select name="<?php echo ($field["name"]); ?>">
                                                    <?php $_result=parse_field_attr($field['extra']);if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($key); ?>" <?php if(($data[$field['name']]) == $key): ?>selected<?php endif; ?>><?php echo ($vo); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                                                </select><?php break;?>
                                            <?php case "select": ?><select name="<?php echo ($field["name"]); ?>">
                                                    <?php $_result=parse_field_attr($field['extra']);if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($key); ?>" <?php if(($data[$field['name']]) == $key): ?>selected<?php endif; ?>><?php echo ($vo); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                                                </select><?php break;?>
                                            <?php case "radio": $_result=parse_field_attr($field['extra']);if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><label class="radio">
                                                        <input type="radio" value="<?php echo ($key); ?>" name="<?php echo ($field["name"]); ?>" <?php if(($data[$field['name']]) == $key): ?>checked="checked"<?php endif; ?>><?php echo ($vo); ?>
                                                    </label><?php endforeach; endif; else: echo "" ;endif; break;?>
                                            <?php case "checkbox": $_result=parse_field_attr($field['extra']);if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><label class="checkbox">
                                                        <input type="checkbox" value="<?php echo ($key); ?>" name="<?php echo ($field["name"]); ?>[]" <?php if(check_document_position($data[$field['name']],$key)): ?>checked="checked"<?php endif; ?>><?php echo ($vo); ?>
                                                    </label><?php endforeach; endif; else: echo "" ;endif; break;?>
                                            <?php case "editor": ?><label class="textarea">
                                                    <textarea name="<?php echo ($field["name"]); ?>"><?php echo ($data[$field['name']]); ?></textarea>
                                                    <?php echo hook('adminArticleEdit', array('name'=>$field['name'],'value'=>$data[$field['name']]));?>
                                                </label><?php break;?>
                                            <?php case "picture": ?><div class="controls">
                                                    <input type="file" id="upload_picture_<?php echo ($field["name"]); ?>">
                                                    <input type="hidden" name="<?php echo ($field["name"]); ?>" id="cover_id_<?php echo ($field["name"]); ?>" value="<?php echo ($data[$field['name']]); ?>"/>
                                                    <div class="upload-img-box">
                                                        <?php if(!empty($data[$field['name']])): ?><div class="upload-pre-item"><img src="/cuiyufan<?php echo (get_cover($data[$field['name']],'path')); ?>"/></div><?php endif; ?>
                                                    </div>
                                                </div>
                                                <script type="text/javascript">
                                                            //上傳圖片
                                                            /* 初始化上傳插件 */
                                                            $("#upload_picture_<?php echo ($field["name"]); ?>").uploadify({
                                                    "height"          : 30,
                                                            "swf"             : "/cuiyufan/Public/static/uploadify/uploadify.swf",
                                                            "fileObjName"     : "download",
                                                            "buttonText"      : "上傳圖片",
                                                            "uploader"        : "<?php echo U('File/uploadPicture',array('session_id'=>session_id()));?>",
                                                            "width"           : 120,
                                                            'removeTimeout'	  : 1,
                                                            'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                                                            "onUploadSuccess" : uploadPicture<?php echo ($field["name"]); ?>,
                                                            'onFallback' : function() {
                                                            alert('未檢測到兼容版本的Flash.');
                                                            }
                                                    });
                                                            function uploadPicture<?php echo ($field["name"]); ?>(file, data){
                                                    var data = $.parseJSON(data);
                                                            var src = '';
                                                            if (data.status){
                                                    $("#cover_id_<?php echo ($field["name"]); ?>").val(data.id);
                                                            src = data.url || '/cuiyufan' + data.path
                                                            $("#cover_id_<?php echo ($field["name"]); ?>").parent().find('.upload-img-box').html(
                                                            '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                                                            );
                                                    } else {
                                                    updateAlert(data.info);
                                                            setTimeout(function(){
                                                            $('#top-alert').find('button').click();
                                                                    $(that).removeClass('disabled').prop('disabled', false);
                                                            }, 1500);
                                                    }
                                                    }
                                                </script><?php break;?>
                                            <?php case "file": ?><div class="controls">
                                                    <input type="file" id="upload_file_<?php echo ($field["name"]); ?>">
                                                    <input type="hidden" name="<?php echo ($field["name"]); ?>" value="<?php echo think_encrypt(json_encode(get_table_field($data[$field['name']],'id','','File')));?>"/>
                                                    <div class="upload-img-box">
                                                        <?php if(isset($data[$field['name']])): ?><div class="upload-pre-file"><span class="upload_icon_all"></span><?php echo (get_table_field($data[$field['name']],'id','name','File')); ?></div><?php endif; ?>
                                                    </div>
                                                </div>
                                                <script type="text/javascript">
                                                    //上傳圖片
                                                    /* 初始化上傳插件 */
                                                    $("#upload_file_<?php echo ($field["name"]); ?>").uploadify({
                                                    "height"          : 30,
                                                            "swf"             : "/cuiyufan/Public/static/uploadify/uploadify.swf",
                                                            "fileObjName"     : "download",
                                                            "buttonText"      : "上傳附件",
                                                            "uploader"        : "<?php echo U('File/upload',array('session_id'=>session_id()));?>",
                                                            "width"           : 120,
                                                            'removeTimeout'	  : 1,
                                                            "onUploadSuccess" : uploadFile<?php echo ($field["name"]); ?>,
                                                            'onFallback' : function() {
                                                            alert('未檢測到兼容版本的Flash.');
                                                            }
                                                    });
                                                            function uploadFile<?php echo ($field["name"]); ?>(file, data){
                                                    var data = $.parseJSON(data);
                                                            if (data.status){
                                                    var name = "<?php echo ($field["name"]); ?>";
                                                            $("input[name=" + name + "]").val(data.data);
                                                            $("input[name=" + name + "]").parent().find('.upload-img-box').html(
                                                            "<div class=\"upload-pre-file\"><span class=\"upload_icon_all\"></span>" + data.info + "</div>"
                                                            );
                                                    } else {
                                                    updateAlert(data.info);
                                                            setTimeout(function(){
                                                            $('#top-alert').find('button').click();
                                                                    $(that).removeClass('disabled').prop('disabled', false);
                                                            }, 1500);
                                                    }
                                                    }
                                                </script><?php break;?>
                                            <?php case "pictures": echo hook('UploadImages', array('name'=>$field['name'],'value'=>$data[$field['name']])); break;?>
                                            <?php default: ?>
                                            <input type="text" class="text input-large" name="<?php echo ($field["name"]); ?>" value="<?php echo ($data[$field['name']]); ?>"><?php endswitch;?>
                                        </div>
                                    </div><?php endif; endif; endforeach; endif; else: echo "" ;endif; ?>
                    </div><?php endforeach; endif; else: echo "" ;endif; ?>

                <div class="form-item cf">
                    <button class="btn submit-btn ajax-post hidden" id="submit" type="submit" target-form="form-horizontal">確 定</button>
                    <a class="btn btn-return" href="<?php echo (cookie('__forward__')); ?>">返 回</a>
                    <?php if(C('OPEN_DRAFTBOX') and (ACTION_NAME == 'add' or $data['status'] == 3)): ?><button class="btn save-btn" url="<?php echo U('article/autoSave');?>" target-form="form-horizontal" id="autoSave">
                            存草稿
                        </button><?php endif; ?>
                    <input type="hidden" name="id" value="<?php echo ((isset($data["id"]) && ($data["id"] !== ""))?($data["id"]):''); ?>"/>
                    <input type="hidden" name="pid" value="<?php echo ((isset($data["pid"]) && ($data["pid"] !== ""))?($data["pid"]):''); ?>"/>
                    <input type="hidden" name="model_id" value="<?php echo ((isset($data["model_id"]) && ($data["model_id"] !== ""))?($data["model_id"]):''); ?>"/>
                    <input type="hidden" name="category_id" value="<?php echo ((isset($data["category_id"]) && ($data["category_id"] !== ""))?($data["category_id"]):''); ?>">
                </div>
            </form>
        </div>
    </div>

        </div>
        <div class="cont-ft">
            <div class="copyright">
                Copyright © <a href="http://iimageonline.com/" target="_blank">I IMAGE STUDIO </a>2015
            </div>
        </div>
    </div>
    <!-- /內容區 -->
    <script type="text/javascript">
    (function(){
        var ThinkPHP = window.Think = {
            "ROOT"   : "/cuiyufan", //當前網站地址
            "APP"    : "/cuiyufan", //當前項目地址
            "PUBLIC" : "/cuiyufan/Public", //項目公共目錄地址
            "DEEP"   : "<?php echo C('URL_PATHINFO_DEPR');?>", //PATHINFO分割符
            "MODEL"  : ["<?php echo C('URL_MODEL');?>", "<?php echo C('URL_CASE_INSENSITIVE');?>", "<?php echo C('URL_HTML_SUFFIX');?>"],
            "VAR"    : ["<?php echo C('VAR_MODULE');?>", "<?php echo C('VAR_CONTROLLER');?>", "<?php echo C('VAR_ACTION');?>"]
        }
    })();
    </script>
    <script type="text/javascript" src="/cuiyufan/Public/static/think.js"></script>
    <script type="text/javascript" src="/cuiyufan/Public/Admin/js/common.js"></script>
    <script type="text/javascript">
        +function(){
            var $window = $(window), $subnav = $("#subnav"), url;
            $window.resize(function(){
                $("#main").css("min-height", $window.height() - 130);
            }).resize();

            /* 左邊菜單高亮 */
            url = window.location.pathname + window.location.search;
            url = url.replace(/(\/(p)\/\d+)|(&p=\d+)|(\/(id)\/\d+)|(&id=\d+)|(\/(group)\/\d+)|(&group=\d+)/, "");
            $subnav.find("a[href='" + url + "']").parent().addClass("current");

            /* 左邊菜單顯示收起 */
            $("#subnav").on("click", "h3", function(){
                var $this = $(this);
                $this.find(".icon").toggleClass("icon-fold");
                $this.next().slideToggle("fast").siblings(".side-sub-menu:visible").
                      prev("h3").find("i").addClass("icon-fold").end().end().hide();
            });

            $("#subnav h3 a").click(function(e){e.stopPropagation()});

            /* 頭部管理員菜單 */
            $(".user-bar").mouseenter(function(){
                var userMenu = $(this).children(".user-menu ");
                userMenu.removeClass("hidden");
                clearTimeout(userMenu.data("timeout"));
            }).mouseleave(function(){
                var userMenu = $(this).children(".user-menu");
                userMenu.data("timeout") && clearTimeout(userMenu.data("timeout"));
                userMenu.data("timeout", setTimeout(function(){userMenu.addClass("hidden")}, 100));
            });

	        /* 表單獲取焦點變色 */
	        $("form").on("focus", "input", function(){
		        $(this).addClass('focus');
	        }).on("blur","input",function(){
				        $(this).removeClass('focus');
			        });
		    $("form").on("focus", "textarea", function(){
			    $(this).closest('label').addClass('focus');
		    }).on("blur","textarea",function(){
			    $(this).closest('label').removeClass('focus');
		    });

            // 導航欄超出窗口高度後的模擬滾動條
            var sHeight = $(".sidebar").height();
            var subHeight  = $(".subnav").height();
            var diff = subHeight - sHeight; //250
            var sub = $(".subnav");
            if(diff > 0){
                $(window).mousewheel(function(event, delta){
                    if(delta>0){
                        if(parseInt(sub.css('marginTop'))>-10){
                            sub.css('marginTop','0px');
                        }else{
                            sub.css('marginTop','+='+10);
                        }
                    }else{
                        if(parseInt(sub.css('marginTop'))<'-'+(diff-10)){
                            sub.css('marginTop','-'+(diff-10));
                        }else{
                            sub.css('marginTop','-='+10);
                        }
                    }
                });
            }
        }();
    </script>
    
    <link href="/cuiyufan/Public/static/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <?php if(C('COLOR_STYLE')=='blue_color') echo '<link href="/cuiyufan/Public/static/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">'; ?>
    <link href="/cuiyufan/Public/static/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/cuiyufan/Public/static/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="/cuiyufan/Public/static/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
    <script type="text/javascript">

                                                        Think.setValue("type", <?php echo ((isset($data["type "]) && ($data["type "] !== ""))?($data["type "]): '""'); ?>);
                                                        Think.setValue("display", <?php echo ((isset($data["display "]) && ($data["display "] !== ""))?($data["display "]): 0); ?>);
                                                        $('#submit').click(function(){
                                                $('#form').submit();
                                                });
                                                        $(function(){
                                                        $('.time').datetimepicker({
                                                        format: 'yyyy-mm-dd hh:ii',
                                                                language:"zh-CN",
                                                                minView:2,
                                                                autoclose:true
                                                        });
                                                                showTab();
                                                                < if condition = "C('OPEN_DRAFTBOX') and (ACTION_NAME eq 'add' or $data['status'] eq 3)" >
                                                                //保存草稿
                                                                var interval;
                                                                $('#autoSave').click(function(){
                                                        var target_form = $(this).attr('target-form');
                                                                var target = $(this).attr('url')
                                                                var form = $('.' + target_form);
                                                                var query = form.serialize();
                                                                var that = this;
                                                                $(that).addClass('disabled').attr('autocomplete', 'off').prop('disabled', true);
                                                                $.post(target, query).success(function(data){
                                                        if (data.status == 1) {
                                                        updateAlert(data.info, 'alert-success');
                                                                $('input[name=id]').val(data.data.id);
                                                        } else{
                                                        updateAlert(data.info);
                                                        }
                                                        setTimeout(function(){
                                                        $('#top-alert').find('button').click();
                                                                $(that).removeClass('disabled').prop('disabled', false);
                                                        }, 1500);
                                                        })

                                                                //重新開始定時器
                                                                clearInterval(interval);
                                                                autoSaveDraft();
                                                                return false;
                                                        });
                                                                //Ctrl+S保存草稿
                                                                $('body').keydown(function(e){
                                                        if (e.ctrlKey && e.which == 83){
                                                        $('#autoSave').click();
                                                                return false;
                                                        }
                                                        });
                                                                //每隔壹段時間保存草稿
                                                                        function autoSaveDraft(){
                                                                        interval = setInterval(function(){
                                                                        //只有基礎信息填寫了，才會觸發
                                                                        var title = $('input[name=title]').val();
                                                                                var name = $('input[name=name]').val();
                                                                                var des = $('textarea[name=description]').val();
                                                                                if (title != '' || name != '' || des != ''){
                                                                        $('#autoSave').click();
                                                                        }
                                                                        }, 1000 * parseInt(<?php echo C('DRAFT_AOTOSAVE_INTERVAL');?>));
                                                                        }
                                                                autoSaveDraft();
                                                                        < /if>

                                                                });
    </script>

</body>
</html>